package com.yt.server.api;

import java.util.Collection;
import java.util.Iterator;
import com.yt.server.api.event.IEventDispatcher;
import com.yt.server.api.event.IEventHandler;
import com.yt.server.api.event.IEventListener;
import com.yt.server.api.event.IEventObservable;
import com.yt.server.api.listeners.IConnectionListener;
import com.yt.server.api.listeners.IScopeListener;

import org.springframework.context.ApplicationContextAware;

/**
 * @author 刘晶
 * @基于Red5作用域设计(拓扑树形结构)
 */
public interface IScope extends IEventObservable, IEventDispatcher,
		IEventHandler, IEventListener, ApplicationContextAware {

	public static final String ROOT_SCOPE = "root.scope";

	public static final String OWNER = "owner";

	public static final String TYPE = "scope.default";

	public static final String SEPARATOR = ":";

	public static final String ALONE_ROOT_NAME = "alone";

	public static final String COMMON_ROOT_NAME = "common";

	public static final String TEMP_ROOT = "temp";

	public static final int UNSET = -1;

	public boolean hasHandler();

	public boolean hasChildScope(String name);

	public boolean addChildScope(IScope scope);

	public boolean createChildScope(String name, String type,
			IConnection owner, boolean persistent);

	public void removeChildScope(IScope scope);

	public void setOwner(IConnection owner);

	public IConnection getOwner();

	public Iterator<String> getScopeNames();

	public Collection<IScope> getParentScopes();

	public Collection<IScope> getChildScopes();

	public Collection<IConnection> getChildScopeOfConnections();

	public Collection<IConnection> getConnections();

	public IScope getScope(String name);

	public IContext getContext();

	public ClassLoader getClassLoader();

	public IScopeHandler getHandler();

	public boolean hasParent();

	public IScope getParent();

	public void setDepth(long depth);

	public long getDepth();

	public String getName();

	public String getType();

	public String getPath();

	public String getId();

	public void lock();

	public void unlock();

	public boolean join(IConnection conn);

	public void leave(String clientId);

	public void addListener(IScopeListener listener);

	public void addListener(IConnectionListener listener);

	public void removeListener(IScopeListener listener);

	public void removeListener(IConnectionListener listener);

	public void notifyConnected(IConnection conn);

	public void notifyDisconnected(IConnection conn);

	public void notifyScopeCreated(IScope scope);

	public void notifyScopeRemoved(IScope scope);
}